﻿@{
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
}

@model LineOfBusiness.Poco.AD_tblUserAccountPolicy


<style>
 fieldset {
    margin: 8px;
    border: 1px solid silver;
    padding: 8px;    
    border-radius: 4px;
}
legend{
    padding: 2px;        
}
</style>

<div>
    <form id="frm">
        <fieldset>
            <legend><strong>@Html.LOBHtmlHelper().Label("lblSelectUser", "Select User Group")</strong></legend>
                 <table style="width:100%">
            <tr>
                <td style="width:120px">
                    @Html.LOBHtmlHelper().Label("lblUserGroup", "User Group")
                </td>
                <td colspan="3">
                    @Html.LOBHtmlHelper().ComboBox("UserGroupID", "tblUserAccount", 0, new { style = "width:100%" })
                </td>
            </tr>
            <tr>
                <td style="width:120px">
                    
                </td>
                <td style="width:120px">
                    <input type="radio" id="UserID" name="select"  checked="checked" onchange="onchangeUserGroup()" />
                    @Html.LOBHtmlHelper().Label("lblUser", "User")
                    
                </td>
                <td style="width:120px">
                    <input type="radio" id="GroupID" name="select"  onchange="onchangeUserGroup()"/>
                    @Html.LOBHtmlHelper().Label("lblGroup", "Group")
                </td>
                <td>
                     <button type="button" class="positive" style="width:100%;height:25px" onclick="Copy()">
                        @Html.LOBHtmlHelper().C("Copy")
                    </button> 
                </td>
            </tr>
        </table>        
        </fieldset>
       
    </form>
</div>


<script type="text/javascript">
    $(document).ready(function ()
    {
        if('@ViewBag.IsUser'=='1')
            SetMultiPredicateComplexForCombo("UserGroupID", "FGroup.Equals(~0)&&!UserGroupID.Equals(~1)", "false|@ViewBag.UserGroupID");
        else
            SetMultiPredicateComplexForCombo("UserGroupID", "FGroup.Equals(~0)&&!UserGroupID.Equals(~1)", "true|@ViewBag.UserGroupID");
    });

    function onchangeUserGroup(e)
    {
        if ($("#UserID").attr("checked") == "checked")
        {
            SetMultiPredicateComplexForCombo("UserGroupID", "FGroup.Equals(~0)&&!UserGroupID.Equals(~1)", "false|@ViewBag.UserGroupID");
        }
        else
        {
            SetMultiPredicateComplexForCombo("UserGroupID", "FGroup.Equals(~0)&&!UserGroupID.Equals(~1)", "true|@ViewBag.UserGroupID");
        }
    }

    function Copy()
    {
        if (IsNullOrEmty(GetCombobox("UserGroupID"))) {
            window.parent.ShowMessageErrorLevel1("FieldNotNull", "FieldNotNull", null, getLabel("lblUserGroup"));
            return;
        }

        PostServer('@Url.Action("Copy","UserPermission")?FromUserID=' + GetCombobox("UserGroupID") + '&ToUserID=@ViewBag.UserGroupID');
        CloseWin(0, idWindow);
    }
</script>